# -*- encoding: utf-8 -*-

from odoo import fields, models


class account_trial_balance_wizard(models.Model):
    _name = 'account.trial.balance.wizard'
    _description = u'试算平衡向导'

    period_id = fields.Many2one('account.period', u'期别', required=False)

    def action_confirm(self):
        self.ensure_one()
        if self.period_id:
            self._cr.execute("""
                    select account_trial_balance_settle(%s,%s);
                """ % (self.period_id.id, self._uid))
            return {
                'name': '试算平衡',
                'type': 'ir.actions.act_window',
                'view_mode': 'tree',
                'res_model': 'account.trial.balance',
            }
